class Solution {
public:
    int isWinner(vector<int>& player1, vector<int>& player2) {
        int ans1 = 0, ans2 = 0;
        int n = player1.size();
        for (int i = 0; i < n; i++) {
            if (i >= 2) {
                if (player1[i - 2] == 10 || player1[i - 1] == 10)ans1 += 2 * player1[i];
                else ans1 += player1[i];
            }
            else if (i == 1) ans1 += (player1[i - 1] == 10 ? 2 * player1[i] : player1[i]);
            else ans1 += player1[i];
        }
        for (int i = 0; i < n; i++) {
            if (i >= 2) {
                if (player2[i - 2] == 10 || player2[i - 1] == 10)ans2 += 2 * player2[i];
                else ans2 += player2[i];
            }
            else if (i == 1) ans2 += (player2[i - 1] == 10 ? 2 * player2[i] : player2[i]);
            else ans2 += player2[i];
        }
        if (ans1 > ans2)return 1;
        else if (ans1 < ans2)return 2;
        return 0;
    }
};